//
//  ShellSort.c
//  AlgorithmLearning
//
//  Created by aron on 2017/11/2.
//  Copyright © 2017年 aron. All rights reserved.
//

#include "ShellSort.h"

void Shellsort(ElementType arr[], int count) {
    int i, j, Increment;
    for (Increment = count / 2; Increment>0; Increment /= 2) {
        for (i = Increment; i<count; i++) {
            ElementType tmp = arr[i];
            for (j = i; j>=Increment; j-=Increment) {
                if (tmp < arr[j-Increment]) {
                    arr[j] = arr[j-Increment];
                } else {
                    break;
                }
            }
            arr[j] = tmp;
        }
    }
}
